package cn.gok.yufa;

/**
 * @ClassName 运算符
 * @Description TODO
 * @Author HP
 * @Date 14:29 2022/7/4
 * @Version 1.0
 **/
public class 运算符 {
    public static void main(String[] args) {
        // 赋值运算();
        位运算();
    }

    private static void 位运算() {
        int i = 2 | 3;//按位或
        int i2 = 2 & 3;
        int i3 = 2 ^ 3;
        int i4 = ~2;
        System.out.println(i + " " + i2 + " " + i3 + " " + i4);
        int i5 = 9 >> 2;
        int i6 = 9 << 2;
        System.out.println(i5 + " " + i6);
        int i7 = (-7) >> 2;
        int i8 = (-7) << 2;
        System.out.println(i7 + " " + i8);
    }

    private static void 赋值运算() {
        int i, j, k;
        i = j = k = 10;
        int x;
        System.out.println(x = 100);//1 对x进行赋值，2返回100
        System.out.println(x == 100);//比较运算
        int x2 = 100;
        int x3;
        System.out.println(x3 = -x2++);
//        System.out.println(-x2++);//-100
        System.out.println(x3 = -++x2);//-101
        System.out.println(x2);//101

    }
}
